# encoding: utf-8
import sys   
reload(sys)
sys.setdefaultencoding('utf-8')
from traceback import print_tb
import matplotlib.pyplot as plt;
import numpy as np;
import pandas as pd

data=pd.read_table("/home/student/桌面/HW2/D.txt",sep=',',header=None)

xx=np.arange(0,13,0.0001)
x=np.zeros(10)
f=np.zeros(10)

for i in range(0,5):
    x[2*i]=data[0][i]
    x[2*i+1]=data[0][i]
for i in range(0,10):
    f[i]=data[1][i]
p=f[0]
for i in range(1,10):
    s=1
    for j in range(0,i):
        s=s*(xx-x[j])
    p=p+s*f[i]
s=np.zeros(130000-1)
xxx=np.zeros(130000-1)
for i in range(0,130000-1):
    s[i]=(p[i+1]-p[i])/0.0001
    xxx[i]=xx[i]
plt.figure()
plt.plot(xxx,s)
plt.title('speed of the car')
plt.savefig('D.png')
